package com.hung.trade.common.client;

import com.hung.trade.common.constants.TradeEnums;
import com.hung.trade.common.protocol.user.QueryUserReq;
import com.hung.trade.common.protocol.user.QueryUserResp;
import org.springframework.web.client.RestTemplate;

/**
 * @author hungki
 * @createTime 2018-10-08 下午 11:46
 */
public class RestClient {
    private static RestTemplate restTemplate=new RestTemplate();

    public QueryUserResp queryUserById(QueryUserReq queryUserReq) {
        return restTemplate.postForObject(TradeEnums.RestServerEnum.USER.getServerUrl(),queryUserReq,QueryUserResp.class,queryUserReq);
    }

    public static void main(String[] args) {
        QueryUserReq queryUserReq = new QueryUserReq();
        queryUserReq.setUserId(2L);
        QueryUserResp queryUserRes = restTemplate.postForObject(TradeEnums.RestServerEnum.USER.getServerUrl()+"/queryUserById",queryUserReq,QueryUserResp.class,queryUserReq);
        System.out.println("queryUserRes = " + queryUserRes);
    }
}
